package ssi.tools;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;

public class AdoptionChecking {
	public static boolean IfAdopted(String animalID, int userID){
		boolean ifadopted = false;
		try{
			Connection connection = new Connector().getConnection();
			Statement statement = connection.createStatement();
			String query = "SELECT COUNT(*) FROM `adoption` WHERE `customerID`='"+userID+"' AND `AnimalID`='"+animalID+"'";
	    	ResultSet rs = statement.executeQuery(query);
	    	rs.next();
	    	if(rs.getInt("COUNT(*)")!=0){
	    		ifadopted = true;
	    	}
		} catch (Exception e){
			e.printStackTrace();
		}
		return ifadopted;
	}
}